// 引入express模块
const express = require('express'); 
const fs = require('fs');

// 创建express app
const app = express();

// 定义/stream路由
app.get('/stream', (req, res) => {
  // 读取file.txt文件并传给响应
  const stream = fs.createReadStream('./file.txt');
  stream.pipe(res); 
});

// 启动服务器,监听3000端口
app.listen(3000);